package Model;

import java.util.ArrayList;
import java.util.List;

public class Pulsator {
    private String result="";
    private int parameterNo=1;
    public String get6DData(String rowData){
        rowData = rowData.replaceAll(" +"," ");
        String resultHex[] = rowData.split(" ");
       /* if(resultHex.length==){}*/
        //剩余总时间
        String remainTimeTotalStr = resultHex[12]+resultHex[13];
        int remainTimeTotal = Integer.parseInt(remainTimeTotalStr,16);
        result=parameterNo+":"+remainTimeTotal+"@";
        parameterNo++;
        //剩余预约总时间
        String remainTimeStr = resultHex[14]+resultHex[15];
        int remainTime = Integer.parseInt(remainTimeStr,16);
        result+=parameterNo+":"+remainTime+"@";
        parameterNo++;
        //整机状态
        String machineStatus = resultHex[16];
        int statusResult = Integer.parseInt(machineStatus,16);
        String statusBinary = Integer.toBinaryString(statusResult);
        while(statusBinary.length()<8){
            statusBinary = "0"+statusBinary;
        }
        //System.out.println(statusBinary);
        char statusZero=statusBinary.charAt(7);
        char statusFirst=statusBinary.charAt(6);
        char statusSecond=statusBinary.charAt(5);
        char statusThird=statusBinary.charAt(4);
        char statusFourth=statusBinary.charAt(3);
        char statusFifth=statusBinary.charAt(2);
        char statusSixth=statusBinary.charAt(1);
        char statusSeventh=statusBinary.charAt(0);
        String statusTotal = "";
        if(statusZero=='1'){
            String TotalMachineStatus0 = "开机";
            statusTotal+=parameterNo+":"+TotalMachineStatus0+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus0 = "关机";
            statusTotal+=parameterNo+":"+TotalMachineStatus0+"@";
            parameterNo++;
        }
        if(statusFirst=='1'){
            String TotalMachineStatus1 = "启动";
            statusTotal+=parameterNo+":"+TotalMachineStatus1+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus1 = "暂停";
            statusTotal+=parameterNo+":"+TotalMachineStatus1+"@";
            parameterNo++;
        }
        if(statusSecond=='1'){
            String TotalMachineStatus2 = "门盖开";
            statusTotal+=parameterNo+":"+TotalMachineStatus2+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus2 = "门盖关";
            statusTotal+=parameterNo+":"+TotalMachineStatus2+"@";
            parameterNo++;
        }
        if(statusThird=='1'){
            String TotalMachineStatus3 = "门盖上锁";
            statusTotal+=parameterNo+":"+TotalMachineStatus3+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus3 = "门盖解锁";
            statusTotal+=parameterNo+":"+TotalMachineStatus3+"@";
            parameterNo++;
        }
        if(statusFourth=='1'){
            String TotalMachineStatus4 = "童锁上锁";
            statusTotal+=parameterNo+":"+TotalMachineStatus4+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus4 = "童锁解锁";
            statusTotal+=parameterNo+":"+TotalMachineStatus4+"@";
            parameterNo++;
        }
        if(statusFifth=='1'){
            String TotalMachineStatus5 = "有洗涤剂";
            statusTotal+=parameterNo+":"+TotalMachineStatus5+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus5 = "无洗涤剂";
            statusTotal+=parameterNo+":"+TotalMachineStatus5+"@";
            parameterNo++;
        }
        if(statusSixth=='1'){
            String TotalMachineStatus6 = "有柔顺剂";
            statusTotal+=parameterNo+":"+TotalMachineStatus6+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus6 = "无柔顺剂";
            statusTotal+=parameterNo+":"+TotalMachineStatus6+"@";
            parameterNo++;
        }
        if(statusSeventh=='1'){
            String TotalMachineStatus7 = "已设置延长待机时间";
            statusTotal+=parameterNo+":"+TotalMachineStatus7+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus7 = "未设置延长待机时间";
            statusTotal+=parameterNo+":"+TotalMachineStatus7+"@";
            parameterNo++;
        }
        result+=statusTotal;
        //洗涤阶段
        String washStageString = resultHex[17];
        Integer washStage = Integer.parseInt(washStageString,16);
        String washStageValue=null;
        switch(washStage){
            case 0:
                washStageValue = "待机/未启动";
                break;
            case 1:
                washStageValue = "预约";
                break;
            case 2:
                washStageValue = "称重";
                break;
            case 3:
                washStageValue = "浸泡";
                break;
            case 4:
                washStageValue = "洗涤";
                break;
            case 5:
                washStageValue = "漂洗";
                break;
            case 6:
                washStageValue = "脱水";
                break;
            case 7:
                washStageValue = "结束";
                break;
            case 8:
                washStageValue = "风干";
                break;
            case 9:
                washStageValue = "风干结束";
                break;
            case 10:
                washStageValue = "抖散";
                break;
            case 11:
                washStageValue = "抖散结束";
                break;
            case 12:
                washStageValue = "留水";
                break;
        }
        result+=parameterNo+":"+washStageValue+"@";
        parameterNo++;
        //洗衣程序
        String washProgram = resultHex[18];
        Integer washProgramValue = Integer.parseInt(washProgram,16);
        String washProgramResult="";
        switch(washProgramValue) {
            case 0:
                washProgramResult="空流程";
                break;
            case 1:
                washProgramResult="常用";
                break;
            case 2:
                washProgramResult="节水";
                break;
            case 3:
                washProgramResult="速洗";
                break;
            case 4:
                washProgramResult="家纺";
                break;
            case 5:
                washProgramResult="牛仔/强力";
                break;
            case 6:
                washProgramResult="标准";
                break;
            case 7:
                washProgramResult="羊毛";
                break;
            case 8:
                washProgramResult="免熨";
                break;
            case 9:
                washProgramResult="羽绒";
                break;
            case 10:
                washProgramResult="轻柔/立体洗";
                break;
            case 11:
                washProgramResult="洗被子";
                break;
            case 12:
                washProgramResult="单脱水";
                break;
            case 13:
                washProgramResult="随心洗";
                break;
            case 14:
                washProgramResult="高端专属洗";
                break;
            case 15:
                washProgramResult="浸泡洗";
                break;
            case 16:
                washProgramResult="桶自洁";
                break;
            case 17:
                washProgramResult="内衣洗";
                break;
            case 18:
                washProgramResult="卡片洗";
                break;
            case 19:
                washProgramResult="运动";
                break;
            case 20:
                washProgramResult="真丝/浣纱";
                break;
            case 21:
                washProgramResult="童装";
                break;
            case 22:
                washProgramResult="婴童";
                break;
            case 23:
                washProgramResult="顽渍";
                break;
            case 24:
                washProgramResult="时间洗";
                break;
            case 25:
                washProgramResult="桶干燥";
                break;
            case 26:
                washProgramResult="消毒洗";
                break;
            case 27:
                washProgramResult="单洗";
                break;
            case 28:
                washProgramResult="单漂";
                break;
            case 29:
                washProgramResult="漂脱";
                break;
            case 30:
                washProgramResult="防过敏";
                break;
            case 31:
                washProgramResult="冲浪洗";
                break;
            case 32:
                washProgramResult="风干";
                break;
            case 33:
                washProgramResult="超净洗";
                break;
            case 34:
                washProgramResult="智慧云洗";
                break;
            case 35:
                washProgramResult="冲锋衣";
                break;
            case 36:
                washProgramResult="羊绒";
                break;
           /* case 37:
                washProgramResult="预留一";
                break;
            case 38:
                washProgramResult="预留二";
                break;*/
           default:
               washProgramResult="N";
               break;
        }
        result += parameterNo+":"+washProgramResult+"@";
        parameterNo++;
        //洗涤剂属性
        String washProperties = resultHex[19];
        Integer washPropertiesValue = Integer.parseInt(washProperties,16);
        String washPropertiesResult="";
        switch(washPropertiesValue){
            case 0:
                washPropertiesResult="普通";
                break;
            case 1:
                washPropertiesResult="浓缩";
                break;
        }
        result +=parameterNo+":"+ washPropertiesResult+"@";
        parameterNo++;
        //特殊功能A
        String specialFunctionA = resultHex[20];
        int specialFunctionAResult = Integer.parseInt(specialFunctionA,16);
        String specialFunctionABinary = Integer.toBinaryString(specialFunctionAResult);
        //补0
        while(specialFunctionABinary.length()<8){
            specialFunctionABinary = "0"+specialFunctionABinary;
        }
        String statusZeroFirstA=specialFunctionABinary.substring(6,8);
        Integer statusZeroFirstAValue = Integer.parseInt(statusZeroFirstA,16);
        String specialAStatus=null;
        switch (statusZeroFirstAValue){
            case 0:
                specialAStatus="无此功能";
                break;
            case 1:
                specialAStatus="有洗涤剂自动投放功能(自动)";
                break;
            case 2:
                specialAStatus="有洗涤剂自动投放功能(轻污)";
                break;
            case 3:
                specialAStatus="有洗涤剂自动投放功能(重污)";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        char statusSecondA=specialFunctionABinary.charAt(5);
        switch (statusSecondA){
            case '0':
                specialAStatus="无此功能";
                break;
            case '1':
                specialAStatus="有柔顺剂自动投放功能";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        char statusThirdA=specialFunctionABinary.charAt(4);
        switch (statusThirdA){
            case '0':
                specialAStatus="无参数记忆功能";
                break;
            case '1':
                specialAStatus="有参数记忆功能";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        char statusFourthA=specialFunctionABinary.charAt(3);
        switch (statusFourthA){
            case '0':
                specialAStatus="无强制删除";
                break;
            case '1':
                specialAStatus="有强制删除";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        char statusFifthA=specialFunctionABinary.charAt(2);
        switch (statusFifthA){
            case '0':
                specialAStatus="未收到生产测试命令";
                break;
            case '1':
                specialAStatus="接收到生产测试命令";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        String statusSixthAndSeventhA=specialFunctionABinary.substring(0,2);
        Integer statusSixthFirstAValue = Integer.parseInt(statusSixthAndSeventhA,16);
        switch (statusSixthFirstAValue){
            case 0:
                specialAStatus="漂洗不需改变";
                break;
            case 1:
                specialAStatus="漂洗增加1次";
                break;
            case 2:
                specialAStatus="漂洗减少1次";
                break;
            case 3:
                specialAStatus="取消后续漂洗";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        //特殊功能B
        String specialFunctionB = resultHex[21];
        int specialFunctionBResult = Integer.parseInt(specialFunctionB,16);
        String specialFunctionBBinary = Integer.toBinaryString(specialFunctionBResult);
        //补0
        while(specialFunctionBBinary.length()<8){
            specialFunctionBBinary = "0"+specialFunctionBBinary;
        }
        String statusZeroFirstB=specialFunctionBBinary.substring(5,8);
        Integer statusZeroFirstBValue = Integer.parseInt(statusZeroFirstB,2);
        String specialBStatus=null;
        switch (statusZeroFirstBValue){
            case 0:
                specialBStatus="无风干";
                break;
            case 1:
                specialBStatus="风干30分钟";
                break;
            case 2:
                specialBStatus="风干60分钟（有风干功能）";
                break;
            case 3:
                specialBStatus="风干90分钟";
                break;
            case 4:
                specialBStatus="智能风干";
                break;
        }
        result+=parameterNo+":"+specialBStatus+"@";
        parameterNo++;
        //第三位预留
        //第四位
        char statusFourthB=specialFunctionBBinary.charAt(3);
        switch (statusFourthB){
            case '0':
                specialBStatus="无烫烫洗功能";
                break;
            case '1':
                specialBStatus="有烫烫洗功能";
                break;
        }
        result+=parameterNo+":"+specialBStatus+"@";
        parameterNo++;
        char statusFifthB=specialFunctionBBinary.charAt(2);
        switch (statusFifthB){
            case '0':
                specialBStatus="无IWASH功能";
                break;
            case '1':
                specialBStatus="有IWASH功能";
                break;
        }
        result+=parameterNo+":"+specialBStatus+"@";
        parameterNo++;
        char statusSixB=specialFunctionBBinary.charAt(1);
        switch (statusSixB){
            case '0':
                specialBStatus="用户未选用智慧洗衣程序";
                break;
            case '1':
                specialBStatus="用户选用智慧洗衣程序";
                break;
        }
        result+=parameterNo+":"+specialBStatus+"@";
        parameterNo++;
        char statusSeventhB=specialFunctionBBinary.charAt(0);
        switch (statusSeventhB){
            case '0':
                specialBStatus="用户未选择夜洗功能";
                break;
            case '1':
                specialBStatus="用户选择夜洗功能";
                break;
        }
        result+=parameterNo+":"+specialBStatus+"@";
        parameterNo++;
        //洗涤周期
        String washCycleStr = resultHex[22] + resultHex[23];
        Integer washCycle = Integer.parseInt(washCycleStr,16);
        result+=parameterNo+":"+washCycle+"@";
        parameterNo++;
        //本次用水量
        String waterUseStr = resultHex[24] + resultHex[25];
        Integer waterUse = Integer.parseInt(waterUseStr,16);
        result+=parameterNo+":"+waterUse+"@";
        parameterNo++;
        //累计用水量
        String totalWaterStr = resultHex[26] + resultHex[27] + resultHex[28] + resultHex[29];
        Integer totalWater = Integer.parseInt(totalWaterStr,16);
        result+=parameterNo+":"+totalWater+"@";
        parameterNo++;
        //本次用电量
        String elecUseStr = resultHex[30] + resultHex[31];
        Integer elecUse = Integer.parseInt(elecUseStr,16);
        result+=parameterNo+":"+elecUse+"@";
        parameterNo++;
        //累计用电量
        String totalElecStr = resultHex[32] + resultHex[33] + resultHex[34] + resultHex[35];
        Integer totalElec = Integer.parseInt(totalElecStr,16);
        result+=parameterNo+":"+totalElec+"@";
        parameterNo++;
        //设定水位
        String waterPositionStr = resultHex[36];
        Integer waterPositon = Integer.parseInt(waterPositionStr,16);
        String waterPositionValue;
        if(waterPositon<=12){
            waterPositionValue = waterPositon.toString();
        }else{
            waterPositionValue="N";
        }
        result+=parameterNo+":"+waterPositionValue+"@";
        parameterNo++;
        //浸泡时间
        String soakTimeStr = resultHex[37];
        Integer soakTime = Integer.parseInt(soakTimeStr,16);
        String soakTimeValue;
        if(soakTime<=60){
            soakTimeValue = soakTime.toString();
        }else{
            soakTimeValue="N";
        }

        result+=parameterNo+":"+soakTimeValue+"@";
        parameterNo++;
        //洗涤时间
        String washTimeStr = resultHex[38] + resultHex[39];
        Integer washTime = Integer.parseInt(washTimeStr,16);
        String washTimeValue = washTime.toString();
        result+=parameterNo+":"+washTimeValue+"@";
        parameterNo++;
        //漂洗次数
        String rinseTimesStr = resultHex[40];
        char cishu=rinseTimesStr.charAt(1);
        int cishuInteger = cishu -'0';
        char yishui=rinseTimesStr.charAt(0);
        int yishuiInteger = yishui -'0';
        String CiShuValue;
        if(yishuiInteger<=2&&cishuInteger<=9){
            CiShuValue = String.valueOf(cishuInteger);
            switch(yishuiInteger){
                case 0:
                    CiShuValue += "无溢水";
                    break;
                case 1:
                    CiShuValue += "溢水";
                    break;
            }

        }else{
            CiShuValue="N";
        }
        result+=parameterNo+":"+CiShuValue+"@";
        parameterNo++;
        //脱水时间
        String DehydrationTimeStr = resultHex[41];
        Integer DehydrationTime = Integer.parseInt(DehydrationTimeStr,16);
        String DehydrationTimeValue;
        if(DehydrationTime<=255){
            DehydrationTimeValue = DehydrationTime.toString();
        }else{
            DehydrationTimeValue="N";
        }
        result+=parameterNo+":"+DehydrationTimeValue+"@";
        parameterNo++;
        //速度设定
        String speedStr = resultHex[42];
        Integer speed = Integer.parseInt(speedStr,16);
        String speedValue;
        if (speed<5){
            speedValue = speed + "档";
        }else{
            speedValue="N";
        }
        result+=parameterNo+":"+speedValue+"@";
        parameterNo++;
        //留水设定
        String remainWaterStr = resultHex[43];
        Integer remainWater = Integer.parseInt(remainWaterStr,16);
        String remainWaterValue="";
        if(remainWater<=5){
            switch(remainWater){
                case 0:
                    remainWaterValue="无留水功能";
                    break;
                case 1:
                    remainWaterValue="留水1次";
                    break;
                case 2:
                    remainWaterValue="留水2次";
                    break;
                case 3:
                    remainWaterValue="留水3次";
                    break;
                case 4:
                    remainWaterValue="留洗涤水";
                    break;
                case 5:
                    remainWaterValue="留浸泡水";
                    break;
            }

        }else{
            remainWaterValue="N";
        }
        result+=parameterNo+":"+remainWaterValue+"@";
        parameterNo++;
        //衣物脏度
        String dirtayStr = resultHex[44];
        Integer dirtay = Integer.parseInt(dirtayStr,16);
        String dirtayValue="";
        if(dirtay<=2){
            switch(dirtay){
                case 0:
                    dirtayValue="轻污";
                    break;
                case 1:
                    dirtayValue="中污";
                    break;
                case 2:
                    dirtayValue="重污";
                    break;
            }
        }else{
            dirtayValue="N";
        }
        result+=parameterNo+":"+dirtayValue+"@";
        parameterNo++;
        //易损程度
        String easyDestoryStr = resultHex[45];
        Integer easyDestory = Integer.parseInt(easyDestoryStr,16);
        String easyDestoryValue="";
        if (easyDestory<=2){
            switch(easyDestory){
                case 0:
                    easyDestoryValue="易损";
                    break;
                case 1:
                    easyDestoryValue="轻微";
                    break;
                case 2:
                    easyDestoryValue="不易损";
                    break;
            }
        }else{
            easyDestoryValue="Ｎ";
        }
        result+=parameterNo+":"+easyDestoryValue+"@";
        parameterNo++;
        //加热温度设定
        String addHotStr = resultHex[46];
        Integer addHot = Integer.parseInt(addHotStr,16);
        String addHotStrValue="";
        if(addHot<=100){
            if(addHot==0){
                addHotStrValue="不加热";
            }else{
                addHotStrValue="加热到"+addHot+"度";
            }
        }else{
            addHotStrValue="N";
        }
        result+=parameterNo+":"+addHotStrValue+"@";
        parameterNo++;
        //resultHex[47];预留
//        //剩余待机时间
//        String remainOnStr = resultHex[48]+resultHex[49];
//        Integer remainOn = Integer.parseInt(remainOnStr,16);
//        String remainOnStrValue="";
//        if(remainOn<=480){
//            remainOnStrValue = "剩余"+remainOn+"分钟";
//        }else{
//            remainOnStrValue = "N";
//        }
//        result+=parameterNo+":"+remainOnStrValue;
        parameterNo=1;
        return result;
    }


    /***
     * 7D
     * ***/
    public String get7DData(String rowData){
        rowData = rowData.replaceAll(" +"," ");
        String resultHex[] = rowData.split(" ");
        //剩余总时间
        String remainTimeTotalStr = resultHex[12]+resultHex[13];
        int remainTimeTotal = Integer.parseInt(remainTimeTotalStr,16);
        result=parameterNo+":"+remainTimeTotal+"@";
        parameterNo++;
        //剩余预约总时间
        String remainTimeStr = resultHex[14]+resultHex[15];
        int remainTime = Integer.parseInt(remainTimeStr,16);
        result+=parameterNo+":"+remainTime+"@";
        parameterNo++;
        //整机状态
        String machineStatus = resultHex[16];
        int statusResult = Integer.parseInt(machineStatus,16);
        String statusBinary = Integer.toBinaryString(statusResult);
        while(statusBinary.length()<8){
            statusBinary = "0"+statusBinary;
        }
        //System.out.println(statusBinary);
        char statusZero=statusBinary.charAt(7);
        char statusFirst=statusBinary.charAt(6);
        char statusSecond=statusBinary.charAt(5);
        char statusThird=statusBinary.charAt(4);
        char statusFourth=statusBinary.charAt(3);
        char statusFifth=statusBinary.charAt(2);
        char statusSixth=statusBinary.charAt(1);
        char statusSeventh=statusBinary.charAt(0);
        String statusTotal = "";
        if(statusZero=='1'){
            String TotalMachineStatus0 = "开机";
            statusTotal+=parameterNo+":"+TotalMachineStatus0+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus0 = "关机";
            statusTotal+=parameterNo+":"+TotalMachineStatus0+"@";
            parameterNo++;
        }
        if(statusFirst=='1'){
            String TotalMachineStatus1 = "启动";
            statusTotal+=parameterNo+":"+TotalMachineStatus1+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus1 = "暂停";
            statusTotal+=parameterNo+":"+TotalMachineStatus1+"@";
            parameterNo++;
        }
        if(statusSecond=='1'){
            String TotalMachineStatus2 = "门盖开";
            statusTotal+=parameterNo+":"+TotalMachineStatus2+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus2 = "门盖关";
            statusTotal+=parameterNo+":"+TotalMachineStatus2+"@";
            parameterNo++;
        }
        if(statusThird=='1'){
            String TotalMachineStatus3 = "门盖上锁";
            statusTotal+=parameterNo+":"+TotalMachineStatus3+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus3 = "门盖解锁";
            statusTotal+=parameterNo+":"+TotalMachineStatus3+"@";
            parameterNo++;
        }
        if(statusFourth=='1'){
            String TotalMachineStatus4 = "童锁上锁";
            statusTotal+=parameterNo+":"+TotalMachineStatus4+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus4 = "童锁解锁";
            statusTotal+=parameterNo+":"+TotalMachineStatus4+"@";
            parameterNo++;
        }
        if(statusFifth=='1'){
            String TotalMachineStatus5 = "有洗涤剂";
            statusTotal+=parameterNo+":"+TotalMachineStatus5+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus5 = "无洗涤剂";
            statusTotal+=parameterNo+":"+TotalMachineStatus5+"@";
            parameterNo++;
        }
        if(statusSixth=='1'){
            String TotalMachineStatus6 = "有柔顺剂";
            statusTotal+=parameterNo+":"+TotalMachineStatus6+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus6 = "无柔顺剂";
            statusTotal+=parameterNo+":"+TotalMachineStatus6+"@";
            parameterNo++;
        }
        if(statusSeventh=='1'){
            String TotalMachineStatus7 = "已设置延长待机时间";
            statusTotal+=parameterNo+":"+TotalMachineStatus7+"@";
            parameterNo++;
        }else{
            String TotalMachineStatus7 = "未设置延长待机时间";
            statusTotal+=parameterNo+":"+TotalMachineStatus7+"@";
            parameterNo++;
        }
        result+=statusTotal;
        //洗涤阶段
        String washStageString = resultHex[17];
        Integer washStage = Integer.parseInt(washStageString,16);
        String washStageValue=null;
        switch(washStage){
            case 0:
                washStageValue = "待机/未启动";
                break;
            case 1:
                washStageValue = "预约";
                break;
            case 2:
                washStageValue = "称重";
                break;
            case 3:
                washStageValue = "浸泡";
                break;
            case 4:
                washStageValue = "洗涤";
                break;
            case 5:
                washStageValue = "漂洗";
                break;
            case 6:
                washStageValue = "脱水";
                break;
            case 7:
                washStageValue = "结束";
                break;
            case 8:
                washStageValue = "风干";
                break;
            case 9:
                washStageValue = "风干结束";
                break;
            case 10:
                washStageValue = "抖散";
                break;
            case 11:
                washStageValue = "抖散结束";
                break;
            case 12:
                washStageValue = "留水";
                break;
        }
        result+=parameterNo+":"+washStageValue+"@";
        parameterNo++;
        //洗衣程序
        String washProgram = resultHex[18];
        Integer washProgramValue = Integer.parseInt(washProgram,16);
        String washProgramResult="";
        switch(washProgramValue) {
            case 0:
                washProgramResult="空流程";
                break;
            case 1:
                washProgramResult="常用";
                break;
            case 2:
                washProgramResult="节水";
                break;
            case 3:
                washProgramResult="速洗";
                break;
            case 4:
                washProgramResult="家纺";
                break;
            case 5:
                washProgramResult="牛仔/强力";
                break;
            case 6:
                washProgramResult="标准";
                break;
            case 7:
                washProgramResult="羊毛";
                break;
            case 8:
                washProgramResult="免熨";
                break;
            case 9:
                washProgramResult="羽绒";
                break;
            case 10:
                washProgramResult="轻柔/立体洗";
                break;
            case 11:
                washProgramResult="洗被子";
                break;
            case 12:
                washProgramResult="单脱水";
                break;
            case 13:
                washProgramResult="随心洗";
                break;
            case 14:
                washProgramResult="高端专属洗";
                break;
            case 15:
                washProgramResult="浸泡洗";
                break;
            case 16:
                washProgramResult="桶自洁";
                break;
            case 17:
                washProgramResult="内衣洗";
                break;
            case 18:
                washProgramResult="卡片洗";
                break;
            case 19:
                washProgramResult="运动";
                break;
            case 20:
                washProgramResult="真丝/浣纱";
                break;
            case 21:
                washProgramResult="童装";
                break;
            case 22:
                washProgramResult="婴童";
                break;
            case 23:
                washProgramResult="顽渍";
                break;
            case 24:
                washProgramResult="时间洗";
                break;
            case 25:
                washProgramResult="桶干燥";
                break;
            case 26:
                washProgramResult="消毒洗";
                break;
            case 27:
                washProgramResult="单洗";
                break;
            case 28:
                washProgramResult="单漂";
                break;
            case 29:
                washProgramResult="漂脱";
                break;
            case 30:
                washProgramResult="防过敏";
                break;
            case 31:
                washProgramResult="冲浪洗";
                break;
            case 32:
                washProgramResult="风干";
                break;
            case 33:
                washProgramResult="超净洗";
                break;
            case 34:
                washProgramResult="智慧云洗";
                break;
            case 35:
                washProgramResult="冲锋衣";
                break;
            case 36:
                washProgramResult="羊绒";
                break;
            case 37:
                washProgramResult="预留一";
                break;
            case 38:
                washProgramResult="预留二";
                break;
        }
        result += parameterNo+":"+washProgramResult+"@";
        parameterNo++;
        //洗涤剂属性
        String washProperties = resultHex[19];
        Integer washPropertiesValue = Integer.parseInt(washProperties,16);
        String washPropertiesResult="";
        switch(washPropertiesValue){
            case 0:
                washPropertiesResult="普通";
                break;
            case 1:
                washPropertiesResult="浓缩";
                break;
        }
        result +=parameterNo+":"+ washPropertiesResult+"@";
        parameterNo++;
        //特殊功能A
        String specialFunctionA = resultHex[20];
        int specialFunctionAResult = Integer.parseInt(specialFunctionA,16);
        String specialFunctionABinary = Integer.toBinaryString(specialFunctionAResult);
        //补0
        while(specialFunctionABinary.length()<8){
            specialFunctionABinary = "0"+specialFunctionABinary;
        }
        String statusZeroFirstA=specialFunctionABinary.substring(6,8);
        Integer statusZeroFirstAValue = Integer.parseInt(statusZeroFirstA,16);
        String specialAStatus=null;
        switch (statusZeroFirstAValue){
            case 0:
                specialAStatus="无此功能";
                break;
            case 1:
                specialAStatus="有洗涤剂自动投放功能(自动)";
                break;
            case 2:
                specialAStatus="有洗涤剂自动投放功能(轻污)";
                break;
            case 3:
                specialAStatus="有洗涤剂自动投放功能(重污)";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        char statusSecondA=specialFunctionABinary.charAt(5);
        switch (statusSecondA){
            case '0':
                specialAStatus="无此功能";
                break;
            case '1':
                specialAStatus="有柔顺剂自动投放功能";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        char statusThirdA=specialFunctionABinary.charAt(4);
        switch (statusThirdA){
            case '0':
                specialAStatus="无参数记忆功能";
                break;
            case '1':
                specialAStatus="有参数记忆功能";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        char statusFourthA=specialFunctionABinary.charAt(3);
        switch (statusFourthA){
            case '0':
                specialAStatus="无强制删除";
                break;
            case '1':
                specialAStatus="有强制删除";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        char statusFifthA=specialFunctionABinary.charAt(2);
        switch (statusFifthA){
            case '0':
                specialAStatus="未收到生产测试命令";
                break;
            case '1':
                specialAStatus="接收到生产测试命令";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        String statusSixthAndSeventhA=specialFunctionABinary.substring(0,2);
        Integer statusSixthFirstAValue = Integer.parseInt(statusSixthAndSeventhA,16);
        switch (statusSixthFirstAValue){
            case 0:
                specialAStatus="漂洗不需改变";
                break;
            case 1:
                specialAStatus="漂洗增加1次";
                break;
            case 2:
                specialAStatus="漂洗减少1次";
                break;
            case 3:
                specialAStatus="取消后续漂洗";
                break;
        }
        result+=parameterNo+":"+specialAStatus+"@";
        parameterNo++;
        //特殊功能B
        String specialFunctionB = resultHex[21];
        int specialFunctionBResult = Integer.parseInt(specialFunctionB,16);
        String specialFunctionBBinary = Integer.toBinaryString(specialFunctionBResult);
        //补0
        while(specialFunctionBBinary.length()<8){
            specialFunctionBBinary = "0"+specialFunctionBBinary;
        }
        String statusZeroFirstB=specialFunctionBBinary.substring(5,8);
        Integer statusZeroFirstBValue = Integer.parseInt(statusZeroFirstB,16);
        String specialBStatus=null;
        switch (statusZeroFirstBValue){
            case 0:
                specialBStatus="无风干";
                break;
            case 1:
                specialBStatus="风干30分钟";
                break;
            case 2:
                specialBStatus="风干60分钟（有风干功能）";
                break;
            case 3:
                specialBStatus="风干90分钟";
                break;
            case 4:
                specialBStatus="智能风干";
                break;
        }
        result+=parameterNo+":"+specialBStatus+"@";
        parameterNo++;
        //第三位预留
        //第四位
        char statusFourthB=specialFunctionBBinary.charAt(3);
        switch (statusFourthB){
            case '0':
                specialBStatus="无烫烫洗功能";
                break;
            case '1':
                specialBStatus="有烫烫洗功能";
                break;
        }
        result+=parameterNo+":"+specialBStatus+"@";
        parameterNo++;
        char statusFifthB=specialFunctionBBinary.charAt(2);
        switch (statusFifthB){
            case '0':
                specialBStatus="无IWASH功能";
                break;
            case '1':
                specialBStatus="有IWASH功能";
                break;
        }
        result+=parameterNo+":"+specialBStatus+"@";
        parameterNo++;
        char statusSixB=specialFunctionBBinary.charAt(1);
        switch (statusSixB){
            case '0':
                specialBStatus="用户未选用智慧洗衣程序";
                break;
            case '1':
                specialBStatus="用户选用智慧洗衣程序";
                break;
        }
        result+=parameterNo+":"+specialBStatus+"@";
        parameterNo++;
        char statusSeventhB=specialFunctionBBinary.charAt(0);
        switch (statusSeventhB){
            case '0':
                specialBStatus="用户未选择夜洗功能";
                break;
            case '1':
                specialBStatus="用户选择夜洗功能";
                break;
        }
        result+=parameterNo+":"+specialBStatus+"@";
        parameterNo++;
        //洗涤周期
        String washCycleStr = resultHex[22] + resultHex[23];
        Integer washCycle = Integer.parseInt(washCycleStr,16);
        result+=parameterNo+":"+washCycle+"@";
        parameterNo++;
        //本次用水量
        String waterUseStr = resultHex[24] + resultHex[25];
        Integer waterUse = Integer.parseInt(waterUseStr,16);
        result+=parameterNo+":"+waterUse+"@";
        parameterNo++;
        //累计用水量
        String totalWaterStr = resultHex[26] + resultHex[27] + resultHex[28] + resultHex[29];
        Integer totalWater = Integer.parseInt(totalWaterStr,16);
        result+=parameterNo+":"+totalWater+"@";
        parameterNo++;
        //本次用电量
        String elecUseStr = resultHex[30] + resultHex[31];
        Integer elecUse = Integer.parseInt(elecUseStr,16);
        result+=parameterNo+":"+elecUse+"@";
        parameterNo++;
        //累计用电量
        String totalElecStr = resultHex[32] + resultHex[33] + resultHex[34] + resultHex[35];
        Integer totalElec = Integer.parseInt(totalElecStr,16);
        result+=parameterNo+":"+totalElec+"@";
        parameterNo++;
        //设定水位
        String waterPositionStr = resultHex[36];
        Integer waterPositon = Integer.parseInt(waterPositionStr,16);
        String waterPositionValue;
        if(waterPositon<=12){
            waterPositionValue = waterPositon + "档";
        }else{
            waterPositionValue="N";
        }
        result+=parameterNo+":"+waterPositionValue+"@";
        parameterNo++;
        //浸泡时间
        String soakTimeStr = resultHex[37];
        Integer soakTime = Integer.parseInt(soakTimeStr,16);
        String soakTimeValue;
        if(soakTime<=60){
            soakTimeValue = soakTime.toString();
        }else{
            soakTimeValue="N";
        }

        result+=parameterNo+":"+soakTimeValue+"@";
        parameterNo++;
        //洗涤时间
        String washTimeStr = resultHex[38] + resultHex[39];
        Integer washTime = Integer.parseInt(washTimeStr,16);
        String washTimeValue = washTime.toString();
        result+=parameterNo+":"+washTimeValue+"@";
        parameterNo++;
        //漂洗次数
        String rinseTimesStr = resultHex[40];
        char cishu=rinseTimesStr.charAt(1);
        int cishuInteger = cishu -'0';
        char yishui=rinseTimesStr.charAt(0);
        int yishuiInteger = yishui -'0';
        String CiShuValue;
        if(yishuiInteger<=2&&cishuInteger<=9){
            CiShuValue = String.valueOf(cishuInteger);
            switch(yishuiInteger){
                case 0:
                    CiShuValue += "无溢水";
                    break;
                case 1:
                    CiShuValue += "溢水";
                    break;
            }

        }else{
            CiShuValue="N";
        }
        result+=parameterNo+":"+CiShuValue+"@";
        parameterNo++;
        //脱水时间
        String DehydrationTimeStr = resultHex[41];
        Integer DehydrationTime = Integer.parseInt(DehydrationTimeStr,16);
        String DehydrationTimeValue;
        if(DehydrationTime<=255){
            DehydrationTimeValue = DehydrationTime.toString();
        }else{
            DehydrationTimeValue="N";
        }
        result+=parameterNo+":"+DehydrationTimeValue+"@";
        parameterNo++;
        //速度设定
        String speedStr = resultHex[42];
        Integer speed = Integer.parseInt(speedStr,16);
        String speedValue;
        if (speed<5){
            speedValue = speed.toString();
        }else{
            speedValue="N";
        }
        result+=parameterNo+":"+speedValue+"@";
        parameterNo++;
        //留水设定
        String remainWaterStr = resultHex[43];
        Integer remainWater = Integer.parseInt(remainWaterStr,16);
        String remainWaterValue="";
        if(remainWater<=5){
            switch(remainWater){
                case 0:
                    remainWaterValue="无留水功能";
                    break;
                case 1:
                    remainWaterValue="留水1次";
                    break;
                case 2:
                    remainWaterValue="留水2次";
                    break;
                case 3:
                    remainWaterValue="留水3次";
                    break;
                case 4:
                    remainWaterValue="留洗涤水";
                    break;
                case 5:
                    remainWaterValue="留浸泡水";
                    break;
            }

        }else{
            remainWaterValue="N";
        }
        result+=parameterNo+":"+remainWaterValue+"@";
        parameterNo++;
        //衣物脏度
        String dirtayStr = resultHex[44];
        Integer dirtay = Integer.parseInt(dirtayStr,16);
        String dirtayValue="";
        if(dirtay<=2){
            switch(dirtay){
                case 0:
                    dirtayValue="轻污";
                    break;
                case 1:
                    dirtayValue="中污";
                    break;
                case 2:
                    dirtayValue="重污";
                    break;
            }
        }else{
            dirtayValue="N";
        }
        result+=parameterNo+":"+dirtayValue+"@";
        parameterNo++;
        //易损程度
        String easyDestoryStr = resultHex[45];
        Integer easyDestory = Integer.parseInt(easyDestoryStr,16);
        String easyDestoryValue="";
        if (easyDestory<=2){
            switch(easyDestory){
                case 0:
                    easyDestoryValue="易损";
                    break;
                case 1:
                    easyDestoryValue="轻微";
                    break;
                case 2:
                    easyDestoryValue="不易损";
                    break;
            }
        }else{
            easyDestoryValue="Ｎ";
        }
        result+=parameterNo+":"+easyDestoryValue+"@";
        parameterNo++;
        //加热温度设定
        String addHotStr = resultHex[46];
        Integer addHot = Integer.parseInt(addHotStr,16);
        String addHotStrValue;
        if(addHot<=100){
            if(addHot==0){
                addHotStrValue="不加热";
            }else{
                addHotStrValue="加热到"+addHot;
            }
        }else{
            addHotStrValue="N";
        }
        result+=parameterNo+":"+addHotStrValue+"@";
        parameterNo++;
        //浊度传感器
        String dirtyStr = resultHex[47];
        String dirtyValue;
        Integer dirty = Integer.parseInt(dirtyStr,16);
        if(dirty>=0&&dirty<=255){
            dirtyValue=dirtay.toString();
        }else {
            dirtyValue="N";
        }
        result+=parameterNo+":"+dirtyValue+"@";
        parameterNo++;
        //温度传感器
        String temperatureStr = resultHex[48];
        String temperatureValue;
        Integer temperature = Integer.parseInt(temperatureStr,16);
        if(temperature>=0&&temperature<=255){
            temperatureValue=temperature.toString();
        }else {
            temperatureValue="N";
        }
        result+=parameterNo+":"+temperatureValue+"@";
        parameterNo++;
        //衣物重量
        String clothesWeightStr = resultHex[49];
        String clothesWeightValue;
        Integer clothesWeight = Integer.parseInt(clothesWeightStr,16);
        if(clothesWeight>=0&&clothesWeight<=255){
            clothesWeightValue=clothesWeight.toString();
        }else {
            clothesWeightValue="N";
        }
        result+=parameterNo+":"+clothesWeightValue+"@";
        parameterNo++;
        //硬度传感器
        String hardNessStr = resultHex[50];
        String hardNessValue;
        Integer hardNess = Integer.parseInt(hardNessStr,16);
        if(hardNess>=0&&hardNess<=255){
            hardNessValue=hardNess.toString();
        }else {
            hardNessValue="N";
        }
        result+=parameterNo+":"+hardNessValue+"@";
        parameterNo++;
        //洗涤剂投放量
        String detergentStr = resultHex[51];
        String detergentValue;
        Integer detergent = Integer.parseInt(detergentStr,16);
        if(detergent>=0&&detergent<=255){
            detergentValue=detergent.toString();
        }else {
            detergentValue="N";
        }
        result+=parameterNo+":"+detergentValue+"@";
        parameterNo++;
        //柔顺剂投放量
        String softStr = resultHex[52];
        String softValue;
        Integer soft = Integer.parseInt(softStr,16);
        if(soft>=0&&soft<=255){
            softValue=soft.toString();
        }else {
            softValue="N";
        }
        result+=parameterNo+":"+softValue+"@";
        parameterNo++;
        //resultHex[53];预留
//        //剩余待机时间
//        String remainOnStr = resultHex[54]+resultHex[55];
//        Integer remainOn = Integer.parseInt(remainOnStr,16);
//        String remainOnStrValue;
//        if(remainOn<=480){
//            remainOnStrValue = "剩余"+remainOn+"分钟";
//        }else{
//            remainOnStrValue = "N";
//        }
//        result+=parameterNo+":"+remainOnStrValue;
        parameterNo=1;
        return result;
    }

    public String getAlarm(String rowData){
        rowData = rowData.replaceAll(" +"," ");
        String resultHex[] = rowData.split(" ");
        String message = resultHex[12]+resultHex[13]+resultHex[14]+resultHex[15];
        System.out.println(message.length());
        //设置多种报警信息
        String binary = "";
        for(int i=0;i<message.length();i++){
            String s = Integer.toBinaryString(Integer.parseInt(String.valueOf(message.charAt(i))));
            //拼接串 拼成4位
            while (s.length()<4){
                s="0"+s;
            }
            binary += s;
        }
        /*System.out.println(binary);
        System.out.println(binary.length());*/
        //根据二进制的所在的位数获取到报警信息
        List<Integer> addr = new ArrayList<Integer>();
        if(binary.contains("1")){
            for(int j=0;j<binary.length();j++){
                    if(String.valueOf(binary.charAt(j)).equals("1")){
                        addr.add(j);
                }
            }
        }else {
            addr.add(32);
        }


        /***
         *
         * 重新定判定报警信息:
         * bianary为0 则解除报警,固定32为解除报警
         * 在binary中第31位(从0开始)出现为:门锁故障
         * 在binary中第30位(从0开始)出现为:排水超时
         * 在binary中第29位(从0开始)出现为:开盖报警
         * 在binary中第28位(从0开始)出现为:脱水异常 (撞桶)
         *
         * 在binary中第27位(从0开始)出现为:进水超时
         * 在binary中第26位(从0开始)出现为:水位传感器异常
         * 在binary中第25位(从0开始)出现为:水位溢出报警
         * 在binary中第24位(从0开始)出现为:变频板通讯异常
         *
         * 在binary中第23位(从0开始)出现为:风干超重报警
         * 在binary中第22位(从0开始)出现为:电源板通讯异常
         * 在binary中第21位(从0开始)出现为:显示板(触摸板)通讯异常
         * 在binary中第20位(从0开始)出现为:无洗涤剂报警
         *
         * 在binary中第19位(从0开始)出现为:无柔顺剂报警
         * 在binary中第18位(从0开始)出现为:霍尔故障
         * 在binary中第17位(从0开始)出现为:定位锁无法完全伸出故障
         * 在binary中第16位(从0开始)出现为:定位锁无法缩回故障
         *
         * 在binary中第15位(从0开始)出现为:流量计故障
         * 在binary中第14位(从0开始)出现为:吊杆称重故障
         * 在binary中第13位(从0开始)出现为:排水阀塞故障
         * 在binary中第12位(从0开始)出现为:温度传感器异常
         *
         * 在binary中第11位(从0开始)出现为:加热管异常
         * 在binary中第10位(从0开始)出现为:自动投放流量计异常
         * **/
       /* System.out.println(addr);*/
        //addr中的信息进行遍历，查找对应的报警信息
        String alarmSignificant="";
        for(int k=0;k<addr.size();k++){
            switch (addr.get(k)){
                case 32:
                    alarmSignificant += "报警解除";
                    alarmSignificant += "@/";
                    break;
                case 31:
                    alarmSignificant += "门锁故障";
                    alarmSignificant += "@E2-1,";
                    break;
                case 30:
                    alarmSignificant += "排水超时";
                    alarmSignificant += "@E1,";
                    break;
                case 29:
                    alarmSignificant += "开盖报警";
                    alarmSignificant += "@E2-1,";
                    break;
                case 28:
                    alarmSignificant += "脱水异常(撞桶)";
                    alarmSignificant += "@E3,";
                    break;
                case 27:
                    alarmSignificant += "进水超时";
                    alarmSignificant += "@E4,";
                    break;
                case 26:
                    alarmSignificant += "水位传感器异常";
                    alarmSignificant += "@FA,";
                    break;
                case 25:
                    alarmSignificant += "水位溢出报警";
                    alarmSignificant += "@F2,";
                    break;
                case 24:
                    alarmSignificant += "变频板通讯异常";
                    alarmSignificant += "@FC1,";
                    break;
                case 23:
                    alarmSignificant += "风干超重报警";
                    alarmSignificant += "@EL,";
                    break;
                case 22:
                    alarmSignificant += "电源板通讯异常";
                    alarmSignificant += "@FC2,";
                    break;
                case 21:
                    alarmSignificant += "显示板(触摸板)通讯异常";
                    alarmSignificant += "@EC,";
                    break;
                case 20:
                    alarmSignificant += "无洗涤剂报警";
                    alarmSignificant += "@ED,";
                    break;
                case 19:
                    alarmSignificant += "无柔顺剂报警";
                    alarmSignificant += "@EB,";
                    break;
                case 18:
                    alarmSignificant += "霍尔故障";
                    alarmSignificant += "@FH,";
                    break;
                case 16:
                    alarmSignificant += "定位锁无法完全伸出故障";
                    alarmSignificant += "@FU,";
                    break;
                case 15:
                    alarmSignificant += "定位锁无法缩回故障";
                    alarmSignificant += "@FD,";
                    break;
                case 14:
                    alarmSignificant += "流量计故障";
                    alarmSignificant += "@FF,";
                    break;
                case 13:
                    alarmSignificant += "吊杆称重故障";
                    alarmSignificant += "@FB,";
                    break;
                case 12:
                    alarmSignificant += "排水阀塞故障";
                    alarmSignificant += "@FP,";
                    break;
                case 11:
                    alarmSignificant += "温度传感器异常";
                    alarmSignificant += "@F3,";
                    break;
                case 10:
                    alarmSignificant += "加热管异常";
                    alarmSignificant += "@F4,";
                    break;
                case 9:
                    alarmSignificant += "自动投放流量计故障";
                    alarmSignificant += "@F0,";
                    break;
            }

        }
      /*  System.out.println(alarmSignificant);*/
        //System.out.println(faultCode);
        //String result= alarmSignificant+"@"+faultCode;
        return alarmSignificant;
    }

    public static void main(String[] args) {
        //String D7 = "FF FF 36 00 00 00 00 00 00 06 7D 01 00 1B 00 00 61 05 01 00 05 20 00 07 00 17 00 00 00 17 00 02 00 00 00 07 01 00 00 00 02 05 00 00 00 00 00 00 00 00 00 00 00 00 00 01 A8";
        String D71= "FF FF 36 00 00 00 00 00 00 06 7D 01 00 1A 00 00 61 05 01 00 05 00 00 07 00 17 00 00 00 E6 00 03 00 00 00 1E 01 00 00 00 02 05 00 00 00 00 00 00 00 00 00 00 00 00 00 01 6E";
        String D6 = "FF FF 30 00 00 00 00 00 00 06 6D 01 00 23 00 00 60 00 01 00 00 00 00 08 00 3F 00 00 04 FA 00 00 00 00 00 6A 06 00 00 0A 01 06 02 00 00 00 00 00 00 00 F0";
        String alarm1 = "FF FF 0E 00 00 00 00 00 00 04 0F 5A 00 00 00 03 7F";
        //String alarm2 = "FF FF 0E 00 00 00 00 00 00 04 0F 5A 00 00 00 84 FF 55";
        Pulsator alarm = new Pulsator();
        String res = alarm.get7DData(D71);
        System.out.println(alarm.getAlarm(alarm1));
        System.out.println("D7:"+res);
        System.out.println("D6:"+D6.split(" ").length);

    }
}
